package com.swancloud.test;

import com.swancloud.api.OSClient;
import com.swancloud.api.types.Facing;
import com.swancloud.model.common.Identifier;
import com.swancloud.openstack.OSFactory;

/**
 * @Author 张立强 - zhangliqiang@asiacom.net.cn
 * @Description
 * @Date 2020-12-16 11:10
 **/
public class OSCommon {
    /**
     * U版 admin 管理员用户
     * @return
     */
    public static OSClient.OSClientV3 getVersionUOpenStack() {
        OSFactory.enableHttpLoggingFilter(true);
        OSClient.OSClientV3 os = OSFactory.builderV3()
                .endpoint("http://swan-controller:5000/v3/")                                            // 认证URL
                .credentials("1604907562200", "swanstack-1604907562200", Identifier.byId("default"))      // 认证用户名和密码已经domainName
                .scopeToProject(Identifier.byName("wodegongsi"), Identifier.byId("default"))               // project名字和demainName
                .perspective(Facing.INTERNAL)                                                              // 取得权限 (INTERNAL,ADMIN,PUBLIC) 默认为PUBLIC
                .authenticate();
        return os;
    }

    /**
     * T版 admin 管理员用户
     * @return
     */
    public static OSClient.OSClientV3 getVersionTOpenStack() {
        OSFactory.enableHttpLoggingFilter(true);
        OSClient.OSClientV3 os = OSFactory.builderV3()
                .endpoint("http://sw-controller:5000/v3/")                                            // 认证URL
                .credentials("admin", "openstack", Identifier.byId("default"))      // 认证用户名和密码已经domainName
                .scopeToProject(Identifier.byName("admin"), Identifier.byId("default"))               // project名字和demainName
                .perspective(Facing.ADMIN)                                                              // 取得权限 (INTERNAL,ADMIN,PUBLIC) 默认为PUBLIC
                .authenticate();
        return os;
    }

    /**
     * S版 admin 管理员用户
     * @return
     */
    public static OSClient.OSClientV3 getVersionSOpenStack() {
        OSFactory.enableHttpLoggingFilter(true);
        OSClient.OSClientV3 os = OSFactory.builderV3()
                .endpoint("http://swanstack01:5000/v3/")                                            // 认证URL
                .credentials("admin", "openstack", Identifier.byId("default"))      // 认证用户名和密码已经domainName
                .scopeToProject(Identifier.byName("admin"), Identifier.byId("default"))               // project名字和demainName
                .perspective(Facing.ADMIN)                                                              // 取得权限 (INTERNAL,ADMIN,PUBLIC) 默认为PUBLIC
                .authenticate();
        return os;
    }
}
